<template>
  <el-dialog title="打款" :close-on-click-modal="false" :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
      <el-form-item label="打款时间" prop="remit_time">
        <!-- <el-input placeholder="" v-model="dataForm.remit_time"></el-input> -->
        <el-date-picker v-model="dataForm.remit_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="银行名称" prop="bank_name">
        <el-input maxlength="50" placeholder="" v-model="dataForm.bank_name"></el-input>
      </el-form-item>
      <el-form-item label="交易流水号" prop="third_pay_code">
        <el-input maxlength="50" placeholder="" v-model="dataForm.third_pay_code"></el-input>
      </el-form-item>
      <el-form-item label="打款人" prop="remit_man">
        <el-input maxlength="20" placeholder="" v-model="dataForm.remit_man"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import {
  treeDataTranslate
} from '@/utils'
import seviceApi from '@/api/serviceApi.js'
export default {
  data () {
    return {
      visible: false,
      dataForm: {
        id: '0',
        remit_time: '',
        third_pay_code: '',
        bank_name: '',
        remit_man: ''
      },
      dataRule: {
        remit_time: [{
          required: true,
          message: '打款时间不能为空',
          trigger: 'blur'
        }],
        bank_name: [{
          required: true,
          message: '银行名称不能为空',
          trigger: 'blur'
        }],
        third_pay_code: [{
          required: true,
          message: '交易流水号不能为空',
          trigger: 'blur'
        }],
        remit_man: [{
          required: true,
          message: '打款人不能为空',
          trigger: 'blur'
        }]
      }
    }
  },

  methods: {
    init (id) {
      this.visible = true
      this.dataForm.id = id
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
      })
    },
    // 提交
    dataFormSubmit () {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          seviceApi.getWithdrawRemit(this.dataForm).then(res => {
            if (res && res.data.code == 200) {
              this.$message({
                showClose: true,
                message: '打款成功',
                type: 'success'
              })
              this.visible = false
              this.$emit('updataList', 1)
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="scss">
</style>
